#ifndef Ncti_H
#define Ncti_H
#include "NctiRenderSceneItem.h"
#include "NctiRenderSegmentItem.h"
#include "NctiRenderRootModelItem.h"
#include "NctiRenderMouseState.h"
#include "NctiRenderMouseEvent.h"

#include "NctiRenderTriangleItem.h"
#include "NctiRenderPolylineItem.h"
#include "NctiRenderVisSelKit.h"
#include "NctiRenderMaterialMappingKit.h"
#include "NctiRenderFeatureKit.h"
#include "NctiViewerRenderer.h"
#include "ncti_dcl.h"
#include "ncti_base.h"
//#define NCTI_SIZE_FILE_PATH			2048

#define NCTI_BUFF_CHUNK_SIZE		(1024*1024)	// 1M

#define NCTI_STRING_FILE_TERMINATOR	"End-of-DisplayObject"
#define NCTI_STRING_NCTI_WORK		"ncti_work"//"/include library/ncti_work"
#define NCTI_STRING_ROOT			"ncti_root"
#define NCTI_SCENE                  "ncti_scene"

#ifdef _M_AMD64
#ifdef WIN32
#define NCTI_HC_KEY	__int64
#elif __GNUC__
#define NCTI_HC_KEY	long
#endif
#else
#ifdef WIN32
#define NCTI_HC_KEY	long
#elif __GNUC__
#define NCTI_HC_KEY	long
#else
#error "message Platform Error in ncti.h. NCTI_HC_KEY must be defined."
#endif
#endif

#ifndef INVALID_KEY
#define INVALID_KEY (-1L)
#endif

#define NCTI_HASH_SIZE 127

#define NCTI_INVALID_INDEX -1

enum EnumNctiCheckExistence
{
	NCTI_NO_EXISTENCE_CHECK,
	NCTI_CHECK_EXISTENCE
};

#define NCTI_VERSION_MAJOR 29 
#define NCTI_VERSION_MINOR 0

enum EnumNctiDoCallbackStatus
{
	NCTI_DO_CBKSTAT_NONE, 
	NCTI_DO_CBKSTAT_PROCESSED, 
	NCTI_DO_CBKSTAT_MOTION_EVENT_FINISHED 
};

enum EnumNctiDoCallbackType
{
	NCTI_DO_CALLBACK_ACTIVE_DOCUMENT_CHANGED
	, NCTI_DO_CALLBACK_SELECT_BROWSER
	, NCTI_DO_CALLBACK_REDRAW
	, NCTI_DO_CALLBACK_DOUBLE_CLICK
	, NCTI_DO_CALLBACK_SINGLE_CLICK
	, NCTI_DO_CALLBACK_DRAGGING
	, NCTI_DO_CALLBACK_RELEASE_BUTTON
	, NCTI_DO_CALLBACK_CAMERA_POSITION_CHANGED
	, NCTI_DO_CALLBACK_MOUSE_MOVE
	, NCTI_DO_CALLBACK_SHOW_CONTEXT_MENU
	, NCTI_DO_CALLBACK_PROCESS_CONTEXT_MENU
	, NCTI_DO_CALLBACK_DISPLAY_CAP_GEOMETRY
	, NCTI_DO_CALLBACK_ERASE_CAP_GEOMETRY
	, NCTI_DO_CALLBACK_ERASE_ISO_SURFACE
	, NCTI_DO_CALLBACK_RENDERING_MODE_CHANGED
	, NCTI_DO_CALLBACK_DISPLAY_ISO_SURFACE
	, NCTI_DO_CALLBACK_PREPROCESS_DO_DELETION
	, NCTI_DO_CALLBACK_PREPROCESS_ENTITY_DELETION
	, NCTI_DO_CALLBACK_EVENT_3DMOUSE
	, NCTI_DO_CALLBACK_WORKPLANE_CHANGED
	, NCTI_DO_CALLBACK_RESET_TIMER
	, NCTI_DO_CALLBACK_TIMER_EVENT
	, NCTI_DO_CALLBACK_PREPROCESS_FILE_SAVE
	, NCTI_DO_CALLBACK_POSTPROCESS_FILE_SAVE
	, NCTI_DO_CALLBACK_PREPROCESS_FILE_RESTORE
	, NCTI_DO_CALLBACK_POSTPROCESS_FILE_RESTORE
	, NCTI_DO_CALLBACK_SELECTION_DATA_CHANGED
	, NCTI_DO_CALLBACK_HISTORY_ADD_TO_OWNER
	, NCTI_DO_CALLBACK_HISTORY_REMOVE_FROM_OWNER
	, NCTI_DO_CALLBACK_UPDATE_SHAPE
	, NCTI_DO_CALLBACK_UPDATE_INSTANCE
	, NCTI_DO_CALLBACK_UPDATE_ATTRIBUTE
	, NCTI_DO_CALLBACK_REMOVE_ATTRIBUTE
	, NCTI_DO_CALLBACK_REBUILD_STRUCTURE
	, NCTI_DO_CALLBACK_ZOOM_FACTOR_CHANGED
	, NCTI_DO_CALLBACK_SLIDER_VALUE_CHANGED
	, NCTI_DO_CALLBACK_MAKE_ONESHELL
	, NCTI_DO_CALLBACK_DELETE_ONESHELL
    , NCTI_DO_CALLBACK_MESH_NODE
    , NCTI_DO_CALLBACK_MESH_NUMBER
};
#define NCTI_HOOPS_IDENTITY_MATRIX {1.0f,0.0f,0.0f,0.0f,0.0f,1.0f,0.0f,0.0f,0.0f,0.0f,1.0f,0.0f,0.0f,0.0f,0.0f,1.0f}

// Component X,Y,Z
#define NCTI_COMP_TYPE_X	0x01
#define NCTI_COMP_TYPE_Y	0x02
#define NCTI_COMP_TYPE_Z	0x04

#define NCTI_SIZE_OBJECT_NAME		128
#define NCTI_SIZE_DOCUMENT_NAME		1024
#define NCTI_NUMBER_MAX_DOCUMENT	256
#define NCTI_SIZE_SEGMENT_NAME		64

enum EnumNctiSelectionShape
{
	NCTI_SELECTION_SHAPE_RECT,
	NCTI_SELECTION_SHAPE_CIRCLE,
	NCTI_SELECTION_SHAPE_POLYGON,
	NCTI_SELECTION_SHAPE_FREEHAND
};

enum EnumNctiMouseEventForSelection
{
	NCTI_SELECT_MOUSE_CLICK,
	NCTI_SELECT_MOUSE_DRAG,
	NCTI_SELECT_NO_MOUSE
};

enum EnumNctiSelectionFilterMode
{
	NCTI_AND,
	NCTI_OR,
	NCTI_OTHER,
};


#define NCTI_KEY_SHIFT		0x01
#define NCTI_KEY_CTRL		0x02
#define NCTI_KEY_ALT		0x04

#define NCTI_SELECT_MODE_CLICK 0x01
#define NCTI_SELECT_MODE_REGION 0x02

#define NCTI_SELECTION_HASH_MAJOR 31
#define NCTI_SELECTION_HASH_MINOR 31

#define NCTI_LOCAL_SELECTION_LIMIT 50

#define	NCTI_PICK_BODY			0x20
#define NCTI_PICK_FACE			0x04
#define	NCTI_PICK_EDGE			0x02
#define	NCTI_PICK_VERTEX		0x01

typedef	unsigned short NctiPickType;

#define NCTI_LOCAL_NUM_MAX_INTERRUPT 20

enum EnumNctiBeginEnd
{
	NCTI_END = false,
	NCTI_BEGIN = true
};

#define NCTI_END_OF_ENUM_TABLE {-9999, nullptr}

#define NCTI_RESABS 1e-6
#define NCTI_RESFIT 1e-3
#define NCTI_RESMCH 1e-10
#define NCTI_RESNOR 1e-10

enum EnumNctiGridDisplayDepth
{
	NCTI_GRID_DEPTH_FRONT,
	NCTI_GRID_DEPTH_BACK,
	NCTI_GRID_DEPTH_NORMAL,
	NCTI_GRID_DEPTH_AUTO
};

enum EnumNctiGridDisplayMode
{
	NCTI_GRID_NO_SHOW,
	NCTI_GRID_DISP_FIX,
	NCTI_GRID_DISP_AUTO
};


enum EnumNctiJobStatus
{
	NCTI_JOB_STATUS_UNKNOWN
	, NCTI_JOB_STATUS_RUNNING
	, NCTI_JOB_STATUS_WAITING
	, NCTI_JOB_STATUS_SUSPEND
	, NCTI_JOB_STATUS_FINISHED
};

#define NCTI_TIMER_ID_MOTION		8	// ID for the timer
#define NCTI_TIMER_ID_AUTO_RUN		9	// ID for the timer
#define NCTI_TIMER_ID_3DMOUSE		10	// ID for the timer
#define NCTI_TIMER_ID_HOOPS			11  // ID for HOOPS timer event
#define NCTI_TIMER_ID_COMMAND		12	// ID for command
#define NCTI_TIMER_ID_UPDATE_SCENE	13	// ID for Update Scene

#define NCIT_POINT_TO_LONG(OBJECT_POINT)\
  abs((long)OBJECT_POINT) % NCTI_HASH_SIZE


enum EnumNctiMenuType
{
	NCTI_MENU_ITEM = 1,
	NCTI_MENU_SEPARATOR
};

enum EnumNctiMenuProcMode
{
	NCTI_SHOW_MENU = 1,
	NCTI_PROCESS_MENU
};

enum EnumSnapType
{
	sModeMid,
	sModeNode,
	sModeVertexs,
	sModeCloser,
	sModeIntersect,
	sModePointDim,
};

#ifndef RGB2FLOAT
#define RGB2FLOAT(val) ((val##f) / 255.0f)
#endif
#endif // !Ncti_H

